package org.deltaset.samples.mvc.user;

import javax.annotation.ManagedBean;
import org.deltaset.faces.DeltasetConfig;
import javax.inject.Inject;
import org.springframework.context.annotation.Scope;
import org.springframework.web.context.WebApplicationContext;

/**
 *
 * @author dmakariev
 */
@ManagedBean("deltasetConfig")
@Scope(value = WebApplicationContext.SCOPE_REQUEST)
public class DeltasetConfigWrapper implements DeltasetConfig {

    private final UserContext uc;

    @Inject
    public DeltasetConfigWrapper(PreferencesRepository preferencesRepository) {
        this.uc = preferencesRepository.loadUserContext();
    }

    /**
     * @return the dateFormat
     */
    @Override
    public String getDateFormat() {
        return uc.getDateFormat();
    }

    /**
     * @return the showPager
     */
    @Override
    public String getShowPager() {
        return uc.getShowPager();
    }

    /**
     * @return the fieldsetPosition
     */
    @Override
    public String getFieldsetPosition() {
        return uc.getFieldsetPosition();
    }

    /**
     * @return the fieldsetWidth
     */
    @Override
    public String getFieldsetWidth() {
        return uc.getFieldsetWidth();
    }

    /**
     * @return the viewType
     */
    @Override
    public String getViewType() {
        return uc.getViewType();
    }
}
